﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Shared.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="Button">
        <Setter Property="Visibility" Value="Visible"/>
        <Setter Property="Foreground" Value="{StaticResource Foreground}"/>
        <Setter Property="Background" Value="{StaticResource BackgroundNormal}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrushNormal}"/>
        <Setter Property="MinHeight" Value="25" />
        <Setter Property="MinWidth" Value="75" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid SnapsToDevicePixels="True">
                        <Border x:Name="ButtonBorder"
                            SnapsToDevicePixels="True"
                            BorderThickness="1"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            Background="{TemplateBinding Background}"/>
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{StaticResource BackgroundHighlighted}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource BorderBrushHighlighted}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Background" Value="{StaticResource BackgroundSelected}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource BorderBrushSelected}"/>
                        </Trigger>
                        <Trigger Property="IsDefault" Value="True">
                            <Setter Property="BorderBrush" Value="{StaticResource BorderBrushSelected}" />
                            <Setter Property="Effect" TargetName="ButtonBorder" >
                                <Setter.Value>
                                    <DropShadowEffect ShadowDepth="0"
                                                      Color="White"
                                                      Opacity="1"
                                                      BlurRadius="3"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value=".5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Button" x:Key="IconButton">
        <Setter Property="Visibility" Value="Visible"/>
        <Setter Property="Foreground" Value="{StaticResource Foreground}"/>
        <Setter Property="Background" Value="{StaticResource BackgroundNormal}"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid SnapsToDevicePixels="True">
                        <Border x:Name="ButtonBorder"
                                SnapsToDevicePixels="True"
                                BorderThickness="1"
                                BorderBrush="Transparent"
                                Background="{TemplateBinding Background}"/>
                        <ContentPresenter x:Name="content" 
                                          HorizontalAlignment="Center" 
                                          VerticalAlignment="Center">
                        </ContentPresenter>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource BackgroundSelected}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value=".5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Button" x:Key="SearchingIpButton" BasedOn="{StaticResource IconButton}">
        <Setter Property="Visibility" Value="Visible"/>
        <Setter Property="Foreground" Value="{StaticResource Foreground}"/>
        <Setter Property="Background" Value="{StaticResource BackgroundNormal}"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid SnapsToDevicePixels="True">
                        <Border x:Name="ButtonBorder"
                                SnapsToDevicePixels="True"
                                BorderThickness="1"
                                BorderBrush="Transparent"
                                Background="{TemplateBinding Background}"/>
                        <ContentPresenter x:Name="content" 
                                          HorizontalAlignment="Center" 
                                          VerticalAlignment="Center"
                                          RenderTransformOrigin="0.5,0.5">
                            <ContentPresenter.RenderTransform>
                                <RotateTransform Angle="0"/>
                            </ContentPresenter.RenderTransform>
                        </ContentPresenter>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=IsSearchingIp}" Value="True">
                            <DataTrigger.EnterActions>
                                <BeginStoryboard Name="NewAnimation">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="content"
                                                         Storyboard.TargetProperty="(Path.RenderTransform).(RotateTransform.Angle)"
                                                         By="360"
                                                         RepeatBehavior="Forever"
                                                         AccelerationRatio="0.2"
                                                         DecelerationRatio="0.4"
                                                         Duration="0:0:2.0"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </DataTrigger.EnterActions>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=IsSearchingIp}" Value="False">
                            <DataTrigger.EnterActions>
                                <StopStoryboard BeginStoryboardName="NewAnimation" />
                            </DataTrigger.EnterActions>
                        </DataTrigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource BackgroundSelected}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value=".5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="LinkButton" TargetType="Button" >
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <ContentPresenter Content="{TemplateBinding Content}" 
                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                      VerticalAlignment="Center" >
                        <ContentPresenter.Resources>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="TextDecorations" Value="Underline" />
                            </Style>
                        </ContentPresenter.Resources>
                    </ContentPresenter>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Visibility" Value="Visible"/>
        <Setter Property="Foreground" Value="{StaticResource Foreground}"/>
        <Setter Property="Background" Value="{StaticResource BackgroundNormal}"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Width" Value="Auto" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{StaticResource BorderBrushSelected}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" Value=".5"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>